package com.flute.tools.data.berkeleydb;

import java.io.File;

import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseConfig;
import com.sleepycat.je.Environment;
import com.sleepycat.je.EnvironmentConfig;

public class BerkeleyHandler {

	private Environment environment;

	public BerkeleyHandler(String home) {
		EnvironmentConfig config = new EnvironmentConfig();
		config.setAllowCreate(true);
		this.environment = new Environment(new File(home), config);
	}

	public Environment getEnvironment() {
		return environment;
	}

	@SuppressWarnings("unused")
	private Database getDatabase(String databaseName) {
		DatabaseConfig dbConfig = new DatabaseConfig();
		dbConfig.setSortedDuplicates(true);
		dbConfig.setAllowCreate(true);
		return environment.openDatabase(null, databaseName, dbConfig);
	}

}
